﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevExpress.Web.ASPxGridView;
using Budget.HelperClasses;
using Budget.SpendingWCFProxy;

namespace Budget.UserControls
{
	public partial class MonthCategorySummary : System.Web.UI.UserControl
	{
		private ISpendingService svc;

		protected void Page_Load( object sender, EventArgs e )
		{
			if ( !IsPostBack )
			{
				LoadMonthCategorySummary();
			}
		}

		public void LoadMonthCategorySummary()
		{
			svc = new SpendingServiceClient();

			IList<MonthSummary> MonthSummaryList = svc.GetMonthCategorySummary( DateTime.Today );

			gvMonthSummary.DataSource = MonthSummaryList;
			gvMonthSummary.DataBind();
		}

		protected void gvMonthSummary_HtmlRowCreated( object sender, DevExpress.Web.ASPxGridView.ASPxGridViewTableRowEventArgs e )
		{
			if ( e.RowType == GridViewRowType.Data )
			{
				string categoryName = e.GetValue( "CategoryName" ).ToString();
				string amountSpent = e.GetValue( "AmountSpent" ).ToString();
				string budgetAmount = e.GetValue( "BudgetAmount" ).ToString();
			}
		}
	}
}